var $ = require('../../utils/Ajax.js');

Page({
  /**
   * 页面的初始数据
   */
  data: {
    Title: null,
    StartTime: null,
    EndTime: null,
    Phone: null,
    Num: null,
    Id: null,
    Price: null,
    Amount: null
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.setNavigationBarTitle({
      title: "退款详情"
    })
    this.setData({
      Title: options.Title,
      StartTime: options.StartTime,
      EndTime: options.EndTime,
      Phone: options.Phone,
      Num: options.Num,
      Id: options.Id,
      Price: options.Price,
      Amount: options.Amount
    })
  },
  RefundBtn: function (){
    var that = this;
    $.Ajax("api/x_order_refund", "POST", {
      id: that.data.Id
    }, function (res) {
      console.log(res)
      if (res.s){
        wx.showToast({
          title: res.m,
          icon: 'none',
          duration: 3000
        })
        setTimeout(function(){
          wx.navigateBack({
            delta: 2
          })
        },3000)
      }else{
        wx.showToast({
          title: res.m,
          icon: 'none',
          duration: 5000
        }) 
      }
    });
  }
})